package com.rui.tools;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import com.rui.function.version.CheckVersionFunction;
import com.rui.function.version.CheckVersionFunction.OnCheckVersionListener;

public class CheckVersionTools
  implements CheckVersionFunction.OnCheckVersionListener
{
  private int appNameId;
  private Context context;
  private int iconId;
  private Intent intent;
  private String url;

  public CheckVersionTools(Context paramContext, String paramString, int paramInt1, int paramInt2, Intent paramIntent)
  {
    this.url = paramString;
    this.iconId = paramInt1;
    this.appNameId = paramInt2;
    this.intent = paramIntent;
    this.context = paramContext;
  }

  public void doCheck()
  {
    new Thread()
    {
      public void run()
      {
        new CheckVersionFunction(CheckVersionTools.this).doCehck(CheckVersionTools.this.url);
      }
    }
    .start();
  }

  public void onException(Exception paramException)
  {
    paramException.printStackTrace();
  }

  public void onTimeOut()
  {
  }

  public void onVersion(float paramFloat, String paramString1, String paramString2)
  {
    try
    {
      if (Float.parseFloat(this.context.getPackageManager().getPackageInfo(this.context.getPackageName(), 0).versionName) < paramFloat)
      {
        NotificationManager localNotificationManager = (NotificationManager)this.context.getSystemService("notification");
        Notification localNotification = new Notification(this.iconId, this.context.getResources().getString(this.appNameId), System.currentTimeMillis());
        localNotification.flags = 16;
        this.intent.putExtra("version", paramFloat);
        this.intent.putExtra("desc", paramString1);
        this.intent.putExtra("url", paramString2);
        this.intent.putExtra("title", this.context.getResources().getString(this.appNameId) + " - 软件升级");
        this.intent.setFlags(335544320);
        PendingIntent localPendingIntent = PendingIntent.getActivity(this.context, 0, this.intent, 134217728);
        localNotification.setLatestEventInfo(this.context, this.context.getResources().getString(this.appNameId), "版本更新提示！\n" + paramString1, localPendingIntent);
        localNotificationManager.notify(0, localNotification);
      }
      return;
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
      while (true)
        localNameNotFoundException.printStackTrace();
    }
  }
}

/* Location:           F:\temp\tools\classes_dex2jar.jar
 * Qualified Name:     com.rui.tools.CheckVersionTools
 * JD-Core Version:    0.6.0
 */